package boot3.mapper;

import boot3.pojo.NoticeUser;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface NoticeUserMapper {
    //插入一条记录
    @Insert("insert notice_user value(#{notice_id},#{user_id},#{is_read})")
    public int insertNotice(NoticeUser noticeUser);
    //将用户已经读过公告的置为已读
    @Update("update notice_user set is_read=1 where user_id=#{user_id} ")
    public boolean updateNotice(String user_id);
    //返回表中的全部记录
    @Select("select * from notice_user")
    public List<NoticeUserMapper> selectAll();
    //根据notice_id获取当前的所有记录
    @Select("select * from notice_user where notice_id=#{notice_id}")
    public List<NoticeUser> selectById(String notice_id);
    //根据Notice_id和user_id查is_read
    @Select("select is_read from notice_user where user_id=#{user_id} and notice_id=#{notice_id}")
    public boolean isRead(String user_id, String notice_id);
}
